﻿using System.Text.Json.Serialization;
using Simple.Common.Helpers;

namespace Simple.Services;

public class ParentModel : ModelBase
{
    /// <summary>
    /// 主键
    /// </summary>
    public Guid? Id { get; set; }

    /// <summary>
    /// 家长名称
    /// </summary>
    [Required(ErrorMessage = "家长名称不能为空")]
    public string? Name { get; set; }

    /// <summary>
    /// 手机号码
    /// </summary>
    [Required(ErrorMessage = "手机号码不能为空")]
    public string? PhoneNumber { get; set; }

    /// <summary>
    /// 幼儿们名称
    /// </summary>
    public string? ChildrensName { get; set; }

    /// <summary>
    /// 幼儿集合
    /// </summary>
    public List<ChildrensListDto>? ChildrenList { get; set; }

    /// <summary>
    /// 幼儿名称与关系
    /// </summary>
    public string? ChildrensNameAndRelationship { get; set; }

    /// <summary>
    /// 工作单位
    /// </summary>
    public string? Workplace { get; set; }

    /// <summary>
    /// 学历
    /// </summary>
    public int? Degree { get; set; }

    /// <summary>
    /// 学历
    /// </summary>
    public string? DegreeStr { get; set; }

    /// <summary>
    /// 是否开通微信端
    /// </summary>
    public bool IsOpenWechat { get; set; } = false;

    /// <summary>
    /// 家长关系(在幼儿编辑家属列表时使用)
    /// </summary>
    public int? Relationship { get; set; }

    /// <summary>
    /// 家长关系(在幼儿编辑家属列表时使用)
    /// </summary>
    public string? RelationshipStr { get; set; }

    /// <summary>
    /// 考勤机卡号
    /// </summary>
    public string? MachineCardNumber { get; set; }

    /// <summary>
    /// 是否主成员
    /// </summary>
    public bool? IsPrincipalMember { get; set; }


    public override void ConfigureMapper(Profile profile)
    {
        profile.CreateMap<Parent, ParentModel>()
            .ForMember(d => d.DegreeStr, options => options.MapFrom(s => EnumHelper.GetDescriptionContent(s.Degree)));

        profile.CreateMap<ParentModel, Parent>();

    }

}

public class ChildrensListDto
{
    /// <summary>
    /// 家属id
    /// </summary>
    public Guid ParentId { get; set; }

    /// <summary>
    /// 家长关系
    /// </summary>
    public int? Relationship { get; set; }
    /// <summary>
    /// 家长关系
    /// </summary>
    public string? RelationshipStr { get; set; }
    /// <summary>
    /// 幼儿Id
    /// </summary>
    public Guid ChildrenId { get; set; }

    /// <summary>
    /// 名字
    /// </summary>
    public string? Name { get; set; }

    /// <summary>
    /// 学号
    /// </summary>
    public string? StudentNumber { get; set; }

    /// <summary>
    /// 出生日期
    /// </summary>
    public DateTime? Birthday { get; set; }

    /// <summary>
    /// 性别
    /// </summary>
    public GenderType Gender { get; set; } = GenderType.Unknown;

    /// <summary>
    /// 家庭地址
    /// </summary>
    public string? HomeAddress { get; set; }

    /// <summary>
    /// 所在班级
    /// </summary>
    public string? ClassesId { get; set; }

    /// <summary>
    /// 登记日期
    /// </summary>
    public DateTime? RegisteredDay { get; set; }

    /// <summary>
    /// 幼儿状态
    /// </summary>
    public EnumChildState ChildState { get; set; } = EnumChildState.NotInClass;

    /// <summary>
    /// 毕业
    /// </summary>
    public DateTime? GradDay { get; set; }

    /// <summary>
    /// 入班时间
    /// </summary>
    public DateTime? ReadingDay { get; set; }

}


public class ModelViewModel
{
    public Guid UserId { get; set; }

    public string UserName { get; set; }

    /// <summary>
    /// 家长关系
    /// </summary>
    public EnumParentRelationship Relationship { get; set; }

    /// <summary>
    /// 工作单位
    /// </summary>
    public string? Workplace { get; set; }

    /// <summary>
    /// 学历
    /// </summary>
    public EnumParentDegree? Degree { get; set; }

    public Guid? ImgId { get; set; }

    /// <summary>
    /// 头像
    /// </summary>
    public string? Avatar { get; set; }

    public string PhoneNumber { get; set; }

    /// <summary>
    /// 登录机构Id
    /// </summary>
    public Guid? OrgId { get; set; }
    /// <summary>
    /// 登录机构名称
    /// </summary>
    public string? OrgName { get; set; }
    /// <summary>
    /// 岗位Id
    /// </summary>
    public Guid? PostId { get; set; }
    /// <summary>
    /// 岗位
    /// </summary>
    public string? PostName { get; set; }

    /// <summary>
    /// 考勤机卡号
    /// </summary>
    public string? MachineCardNumber { get; set; }

    public string RealName { get; set; }

}

public class NoImgParentModel
{
    public string ChidId { get; set; }
    public string ChidName { get; set; }

    public string ChidClassName { get; set; }

    public string ParentName { get; set; }

    public string ImgId { get; set; }
}
